﻿Public Class GetStringDialog
  Private _doCancel As Boolean = False
  Private _doOK As Boolean = False

  Public Overrides Property ForeColor() As System.Drawing.Color
    Get
      Return MyBase.ForeColor
    End Get
    Set(ByVal value As System.Drawing.Color)
      MyBase.ForeColor = value
      Me.LabelString.ForeColor = value
      Me.TextBoxString.ForeColor = value
    End Set
  End Property

  Public Overrides Property BackColor() As System.Drawing.Color
    Get
      Return MyBase.BackColor
    End Get
    Set(ByVal value As System.Drawing.Color)
      MyBase.BackColor = value
      Me.LabelString.BackColor = value
    End Set
  End Property

  Public Property BackColorTextBox() As Color
    Get
      Return Me.TextBoxString.BackColor
    End Get
    Set(ByVal value As Color)
      Me.TextBoxString.BackColor = value
    End Set
  End Property

  Public Property [Label]() As String
    Get
      Return Me.LabelString.Text
    End Get
    Set(ByVal value As String)
      Me.LabelString.Text = value
    End Set
  End Property

  Public Property [String]() As String
    Get
      Return Me.TextBoxString.Text
    End Get
    Set(ByVal value As String)
      Me.TextBoxString.Text = value
    End Set
  End Property

  Private Sub MenuItemOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemOK.Click
    Me.DialogResult = Windows.Forms.DialogResult.OK
    Me.Close()
  End Sub

  Private Sub MenuItemCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemCancel.Click
    Me.DialogResult = Windows.Forms.DialogResult.Cancel
    Me.Close()
  End Sub

  Private Sub TextBoxString_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TextBoxString.KeyDown
    Me._doCancel = False
    Me._doOK = False
    If e.KeyCode = Keys.Escape Then
      Me._doCancel = True
    ElseIf e.KeyCode = Keys.Enter Then
      Me._doOK = True
    End If
  End Sub

  Private Sub TextBoxString_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TextBoxString.KeyUp
    If Me._doCancel AndAlso e.KeyCode = Keys.Escape Then
      Me.MenuItemCancel_Click(sender, EventArgs.Empty)
    ElseIf Me._doOK AndAlso e.KeyCode = Keys.Enter Then
      Me.MenuItemOK_Click(sender, EventArgs.Empty)
    Else
      Me._doCancel = False
      Me._doOK = False
    End If
  End Sub
End Class